package com.bjpowernode.money.utils;

import java.util.Random;

/**
 * @author ZHAOZHENYU
 * @since 2022/10/18
 * 验证码工具类
 */
public class YzmCodeUtils {

    /**
     * 生成指定长度的验证码
     * @param len
     * @return
     */
    public static String generateYzmCode(int len){
        StringBuilder sb = new StringBuilder();
        Random random = new Random();
        for (int i = 0; i < len; i++) {
//            sb.append(Math.round(Math.random() * 9));
            sb.append(random.nextInt(10));
        }
        return sb.toString();
    }

    public static void main(String[] args) {
        System.out.println(generateYzmCode(6));
    }

}
